/*
 * ChatClient.h
 *
 *  Created on: 23.10.2011
 *      Author: niea
 */

#ifndef CHATCLIENT_H_
#define CHATCLIENT_H_

#include <string>
#include <pthread.h>

#include "ISocket.h"

class ChatClient {
public:
	ChatClient();
	virtual ~ChatClient();
	void setName(std::string const& name);

	void setPort(size_t port);
	void assignSocket(ISocket *tcp_socket);
	void pingServers();
	void connect(std::string ip);
	void disconnect();
	void sendMessage(std::string message);
	void listClients();
	void showHistory();

private:
	std::string m_name;
	const std::string m_version;
	size_t m_port;
	ISocket *m_tcp_socket;
	pthread_t m_thread;
	std::vector<char> m_raw_message;
	std::vector<std::string> m_block_messages;
	bool m_thread_stop_req;
	bool m_connected;
	std::string m_server_timestamp;

	ChatClient(ChatClient const&);
	void operator =(ChatClient const&);

	int startThread();
	void stopThread();
	static void* threadProcStarter(void* obj);
	void threadProc();
};

#endif /* CHATCLIENT_H_ */
